//Replication data for Shelef, Nadav; Jamison, Anne, 2024, "Replication Data for: Domestic legitimacy, coethnics abroad, and the shape of the homeland", https://doi.org/10.7910/DVN/FWK7IN, Harvard Dataverse

//This do-file replicates all analyses in the body of the paper, except Figures 1-3. Pleaes see a separate do-file for Figures 1-3, which require a different data configuration.

//Computed on Stata 17.0 SE

//load data
use "cox data.dta"



***********
***********
//Figure 4: Changes in Croatian legitimization strategies
***********
***********
//use V-DEM (version 11)

gen nationalist_ideology=v2exl_legitideolcr_0*v2exl_legitideol
twoway (line nationalist_ideology year if country_name=="Croatia"   & year>1990, lpattern(dash) lcolor(black))  (line v2exl_legitratio year if country_name=="Croatia" & year>1990, lcolor(black))



***********
***********
//Table 1: Controlling for sources of endogeneity
***********
***********

stset time if potato_any_ModifiedEPR ==1 & colony==0, failure(homeland) exit(time .) origin(time0_minus1) id(id)

//REGIME TYPE

***//Regime type -- Main result 

stcox mid_current priormid i.coethnic_presence_tek_mod##i.poly_binary_dem1other0 econ_value_all cincrat_updtd_clclpwr capital_distance_ln global_qtile strata2 strata3 strata4up regimeage_Vdem, shared(id) forceshared efron
estat phtest, rank detail

*TVC needed (.1): priormid econ_value_all capital_distance_ln regimeage_Vdem  strata2 strata3 strata4up
stcox mid_current priormid i.coethnic_presence_tek_mod##i.poly_binary_dem1other0 econ_value_all cincrat_updtd_clclpwr capital_distance_ln global_qtile strata2 strata3 strata4up regimeage_Vdem, tvc( priormid econ_value_all capital_distance_ln regimeage_Vdem strata2 strata3 strata4up) texp(ln(_t)) shared(id) forceshared efron allbase
 eststo main_aut
 estimates save "main_aut", replace


***//Regime type -- Group size 

stcox mid_current priormid i.coethnic_presence_tek_mod##i.poly_binary_dem1other0 econ_value_all cincrat_updtd_clclpwr capital_distance_ln global_qtile strata2 strata3 strata4up regimeage_Vdem sum_tek_group_size_gain, shared(id) forceshared efron
estat phtest, rank detail


*TVC needed (.1): priormid econ_value_all capital_distance_ln regimeage_Vdem  strata2 strata3 strata4up

stcox mid_current priormid i.coethnic_presence_tek_mod##i.poly_binary_dem1other0 econ_value_all cincrat_updtd_clclpwr capital_distance_ln global_qtile strata2 strata3 strata4up regimeage_Vdem sum_tek_group_size_gain, tvc( priormid econ_value_all capital_distance_ln regimeage_Vdem strata2 strata3 strata4up) texp(ln(_t)) shared(id) forceshared efron allbase
 eststo sum_tek_group_size_gain_aut
 estimates save "sum_tek_group_size_gain_aut", replace

***//Regime type -- Historical ELF sq. 

stcox mid_current priormid i.coethnic_presence_tek_mod##i.poly_binary_dem1other0 econ_value_all cincrat_updtd_clclpwr capital_distance_ln global_qtile strata2 strata3 strata4up regimeage_Vdem efindex efindex_squared, shared(id) forceshared efron
estat phtest, rank detail

*TVC needed (.1):   priormid i.coethnic_presence_tek_mod##i.poly_binary_dem1other0 econ_value_all   regimeage_Vdem efindex efindex_squared  strata2 strata3 strata4up

stcox mid_current priormid i.coethnic_presence_tek_mod##i.poly_binary_dem1other0 econ_value_all cincrat_updtd_clclpwr capital_distance_ln global_qtile strata2 strata3 strata4up regimeage_Vdem efindex efindex_squared, tvc(priormid econ_value_all   regimeage_Vdem efindex efindex_squared  strata2 strata3 strata4up) texp(ln(_t)) shared(id) forceshared efron allbase
 eststo EFIndex2_nodecol
 estimates save "EFIndex2_nodecol", replace

***//Regime type -- Polarization 

stcox mid_current priormid i.coethnic_presence_tek_mod##i.poly_binary_dem1other0 econ_value_all cincrat_updtd_clclpwr capital_distance_ln global_qtile strata2 strata3 strata4up regimeage_Vdem actv_groups_count_fill , shared(id) forceshared efron
estat phtest, rank detail

*TVC needed (.1): prio econ cincrat_updtd_clclpwr capital_distance_ln actv_groups_count_fill strata2 strata3 strata4up

stcox mid_current priormid i.coethnic_presence_tek_mod##i.poly_binary_dem1other0 econ_value_all cincrat_updtd_clclpwr capital_distance_ln global_qtile strata2 strata3 strata4up regimeage_Vdem actv_groups_count_fill, tvc(priormid econ_value_all cincrat_updtd_clclpwr capital_distance_ln actv_groups_count_fill strata2 strata3 strata4up) texp(ln(_t)) shared(id) forceshared efron
 eststo eprpolar_nodecol
 estimates save "eprpolar_nodecol", replace

***//Regime type -- State capacity 

stcox mid_current priormid i.coethnic_presence_tek_mod##i.poly_binary_dem1other0 econ_value_all cincrat_updtd_clclpwr capital_distance_ln global_qtile strata2 strata3 strata4up regimeage_Vdem statecapacitycomprehensive , shared(id) forceshared efron
estat phtest, rank detail

//tvc needed: priormid cincrat_updtd_clclpwr capital_distance_ln regimeage_Vdem

stcox mid_current priormid i.coethnic_presence_tek_mod##i.poly_binary_dem1other0 econ_value_all cincrat_updtd_clclpwr capital_distance_ln global_qtile strata2 strata3 strata4up regimeage_Vdem statecapacitycomprehensive, tvc(priormid cincrat_updtd_clclpwr capital_distance_ln regimeage_Vdem  strata2 strata3 strata4up) texp(ln(_t)) shared(id) forceshared efron
 eststo cap_nodecol
 estimates save "cap_nodecol", replace


***//Regime type -- New state

stcox mid_current priormid i.coethnic_presence_tek_mod##i.poly_binary_dem1other0 econ_value_all cincrat_updtd_clclpwr capital_distance_ln global_qtile strata2 strata3 strata4up regimeage_Vdem new_state_5_lose, shared(id) forceshared efron

estat phtest, rank detail


*TVC needed (.1): priormid econ_value_all capital_distance_ln regimeage_Vdem  strata2 strata3 strata4up

stcox mid_current priormid i.coethnic_presence_tek_mod##i.poly_binary_dem1other0 econ_value_all cincrat_updtd_clclpwr capital_distance_ln global_qtile strata2 strata3 strata4up regimeage_Vdem new_state_5_lose, tvc(priormid econ_value_all capital_distance_ln regimeage_Vdem strata2 strata3 strata4up) texp(ln(_t)) shared(id) forceshared efron
eststo newstate_nodecol
estimates save "newstate_nodecol", replace

***//Regime type -- Clientelistic states 

stcox mid_current priormid i.coethnic_presence_tek_mod##i.poly_binary_dem1other0 econ_value_all cincrat_updtd_clclpwr capital_distance_ln global_qtile strata2 strata3 strata4up regimeage_Vdem v2xnp_client, shared(id) forceshared efron
estat phtest, rank detail

stcox mid_current priormid i.coethnic_presence_tek_mod##i.poly_binary_dem1other0 econ_value_all cincrat_updtd_clclpwr capital_distance_ln global_qtile strata2 strata3 strata4up regimeage_Vdem v2xnp_client, tvc(priormid econ_value_all cincrat_updtd_clclpwr  regimeage_Vdem  strata2 strata3 strata4up) texp(ln(_t)) shared(id) forceshared efron

eststo clientelistic_nodecol
estimates save "clientelistic_nodecol", replace

***//Regime type -- Clients of same superpower 

stcox mid_current priormid i.coethnic_presence_tek_mod##i.poly_binary_dem1other0 econ_value_all cincrat_updtd_clclpwr capital_distance_ln global_qtile ClientRelation3 strata2 strata3 strata4up regimeage_Vdem, shared(id) forceshared efron
estat phtest, rank detail

stcox mid_current priormid i.coethnic_presence_tek_mod##i.poly_binary_dem1other0 econ_value_all cincrat_updtd_clclpwr capital_distance_ln global_qtile ClientRelation3 strata2 strata3 strata4up regimeage_Vdem, tvc(priormid econ_value_all capital_distance_ln  regimeage_Vdem  strata2 strata3 strata4up) texp(ln(_t)) shared(id) forceshared efron

eststo CR3_nodecol
estimates save "CR3_nodecol", replace

***//Regime type -- Clients of opposing superpowers
stcox mid_current priormid i.coethnic_presence_tek_mod##i.poly_binary_dem1other0 econ_value_all cincrat_updtd_clclpwr capital_distance_ln global_qtile ClientRelation4 strata2 strata3 strata4up regimeage_Vdem, shared(id) forceshared efron
estat phtest, rank detail

stcox mid_current priormid i.coethnic_presence_tek_mod##i.poly_binary_dem1other0 econ_value_all cincrat_updtd_clclpwr capital_distance_ln global_qtile ClientRelation4 strata2 strata3 strata4up regimeage_Vdem, tvc(priormid econ_value_all capital_distance_ln ClientRelation4 regimeage_Vdem  strata2 strata3 strata4up) texp(ln(_t)) shared(id) forceshared efron

eststo CR4_nodecol
estimates save "CR4_nodecol", replace


//PROPORTION EXCLUDED

stset time if potato_any_ModifiedEPR ==1 & colony==0, failure(homeland) exit(time .) origin(time0_minus1) id(id)

***//Proportion excluded -- Main result 

stcox mid_current priormid i.coethnic_presence_tek_mod##c.ln_losingstate_exclpop econ_value_all cincrat_updtd_clclpwr capital_distance_ln global_qtile strata2 strata3 strata4up regimeage_Vdem, shared(id) forceshared efron
estat phtest, rank detail

*TVC needed (.1): priormid econ_value_all capital_distance_ln regimeage_Vdem  strata2 strata3 strata4up
stcox mid_current priormid i.coethnic_presence_tek_mod##c.ln_losingstate_exclpop econ_value_all cincrat_updtd_clclpwr capital_distance_ln global_qtile strata2 strata3 strata4up regimeage_Vdem, tvc( priormid econ_value_all capital_distance_ln regimeage_Vdem  strata2 strata3 strata4up) texp(ln(_t)) shared(id) forceshared efron allbase
 eststo main_eth
 estimates save "main_eth", replace

***//Proportion excluded -- Group size 

stcox mid_current priormid i.coethnic_presence_tek_mod##c.ln_losingstate_exclpop econ_value_all cincrat_updtd_clclpwr capital_distance_ln global_qtile strata2 strata3 strata4up regimeage_Vdem sum_tek_group_size_gain, shared(id) forceshared efron
estat phtest, rank detail


*TVC needed (.1): priormid econ_value_all capital_distance_ln regimeage_Vdem sum_tek_group_size_gain strata2 strata3 strata4up

stcox mid_current priormid i.coethnic_presence_tek_mod##c.ln_losingstate_exclpop econ_value_all cincrat_updtd_clclpwr capital_distance_ln global_qtile strata2 strata3 strata4up regimeage_Vdem sum_tek_group_size_gain, tvc( priormid econ_value_all capital_distance_ln regimeage_Vdem sum_tek_group_size_gain  strata2 strata3 strata4up) texp(ln(_t)) shared(id) forceshared efron allbase
 eststo sum_tek_group_size_gain_eth
 estimates save "sum_tek_group_size_gain_eth", replace

***//Proportion excluded -- Historical ELF sq. 

 stcox mid_current priormid i.coethnic_presence_tek_mod##c.ln_losingstate_exclpop econ_value_all cincrat_updtd_clclpwr capital_distance_ln global_qtile strata2 strata3 strata4up regimeage_Vdem efindex efindex_squared, shared(id) forceshared efron
estat phtest, rank detail

 *TVC needed (.1):   priormid cincrat_updtd_clclpwr regimeage_Vdem efindex efindex_squared
stcox mid_current priormid i.coethnic_presence_tek_mod##c.ln_losingstate_exclpop econ_value_all cincrat_updtd_clclpwr capital_distance_ln global_qtile strata2 strata3 strata4up regimeage_Vdem efindex efindex_squared, tvc(priormid cincrat_updtd_clclpwr regimeage_Vdem efindex efindex_squared) texp(ln(_t)) shared(id) forceshared efron allbase
 eststo EFIndex2_nodecol_excperln_s
 estimates save "EFIndex2_nodecol_excperln_s", replace

***//Proportion excluded -- Polarization 

stcox mid_current priormid i.coethnic_presence_tek_mod##c.ln_losingstate_exclpop econ_value_all cincrat_updtd_clclpwr capital_distance_ln global_qtile strata2 strata3 strata4up regimeage_Vdem actv_groups_count_fill , shared(id) forceshared efron
estat phtest, rank detail

*TVC needed (.1): priormid cincrat_updtd_clclpwr capital_distance_ln actv_groups_count_fill strata2 strata3 strata4up

stcox mid_current priormid i.coethnic_presence_tek_mod##c.ln_losingstate_exclpop econ_value_all cincrat_updtd_clclpwr capital_distance_ln global_qtile strata2 strata3 strata4up regimeage_Vdem actv_groups_count_fill, tvc(priormid cincrat_updtd_clclpwr capital_distance_ln actv_groups_count_fill strata2 strata3 strata4up) texp(ln(_t)) shared(id) forceshared efron
 eststo eprpolar_nodecol_excln
 estimates save "eprpolar_nodecol_excln", replace

***//Proportion excluded -- State capacity 

stcox mid_current priormid i.coethnic_presence_tek_mod##c.ln_losingstate_exclpop econ_value_all cincrat_updtd_clclpwr capital_distance_ln global_qtile strata2 strata3 strata4up regimeage_Vdem statecapacitycomprehensive , shared(id) forceshared efron
estat phtest, rank detail

*tvc needed: priormid capital_distance_ln regimeage_Vdem

stcox mid_current priormid i.coethnic_presence_tek_mod##c.ln_losingstate_exclpop econ_value_all cincrat_updtd_clclpwr capital_distance_ln global_qtile strata2 strata3 strata4up regimeage_Vdem statecapacitycomprehensive, tvc(priormid capital_distance_ln regimeage_Vdem  strata2 strata3 strata4up) texp(ln(_t)) shared(id) forceshared efron
 eststo cap_nodecol_excln
 estimates save "cap_nodecol_excln", replace

***//Proportion excluded -- New state

stcox mid_current priormid i.coethnic_presence_tek_mod##c.ln_losingstate_exclpop econ_value_all cincrat_updtd_clclpwr capital_distance_ln global_qtile strata2 strata3 strata4up regimeage_Vdem new_state_5_lose, shared(id) forceshared efron
estat phtest, rank detail
 

*TVC needed (.1): priormid   capital_distance_ln regimeage_Vdem new_state_5_lose strata2 strata3 strata4up

stcox mid_current priormid i.coethnic_presence_tek_mod##c.ln_losingstate_exclpop econ_value_all cincrat_updtd_clclpwr capital_distance_ln global_qtile strata2 strata3 strata4up regimeage_Vdem new_state_5_lose, tvc(priormid   capital_distance_ln regimeage_Vdem new_state_5_lose strata2 strata3 strata4up) texp(ln(_t)) shared(id) forceshared efron
eststo newstate_nodecol_excperln
estimates save "newstate_nodecol_excperln", replace

***//Proportion excluded -- Clientelistic states 

stcox mid_current priormid i.coethnic_presence_tek_mod##c.ln_losingstate_exclpop econ_value_all cincrat_updtd_clclpwr capital_distance_ln global_qtile strata2 strata3 strata4up regimeage_Vdem v2xnp_client, shared(id) forceshared efron

*estat phtest, rank detail

stcox mid_current priormid i.coethnic_presence_tek_mod##c.ln_losingstate_exclpop econ_value_all cincrat_updtd_clclpwr capital_distance_ln global_qtile strata2 strata3 strata4up regimeage_Vdem v2xnp_client, tvc(priormid capital_distance_ln    regimeage_Vdem  strata2 strata3 strata4up) texp(ln(_t)) shared(id) forceshared efron

eststo clientel_nodecol_excperln
estimates save "clientel_nodecol_excperln", replace

***//Proportion excluded -- Clients of same superpower 

stcox mid_current priormid i.coethnic_presence_tek_mod##c.ln_losingstate_exclpop econ_value_all cincrat_updtd_clclpwr capital_distance_ln global_qtile strata2 strata3 strata4up regimeage_Vdem ClientRelation3, shared(id) forceshared efron
estat phtest, rank detail
 

*TVC needed (.1): priormid econ_value_all cincrat_updtd_clclpwr capital_distance_ln global_qtile regimeage_Vdem  strata2 strata3 strata4up

stcox mid_current priormid i.coethnic_presence_tek_mod##c.ln_losingstate_exclpop econ_value_all cincrat_updtd_clclpwr capital_distance_ln global_qtile strata2 strata3 strata4up regimeage_Vdem ClientRelation3, tvc(priormid econ_value_all cincrat_updtd_clclpwr capital_distance_ln global_qtile regimeage_Vdem  strata2 strata3 strata4up) texp(ln(_t)) shared(id) forceshared efron

eststo client3_nodecol_excperln
estimates save "client3_nodecol_excperln", replace

***//Proportion excluded -- Clients ofopposing superpowers

stcox mid_current priormid i.coethnic_presence_tek_mod##c.ln_losingstate_exclpop econ_value_all cincrat_updtd_clclpwr capital_distance_ln global_qtile strata2 strata3 strata4up regimeage_Vdem ClientRelation4, shared(id) forceshared efron
estat phtest, rank detail

*TVC needed (.1): priormid econ_value_all cincrat_updtd_clclpwr capital_distance_ln  regimeage_Vdem  strata2 strata3 strata4up

stcox mid_current priormid i.coethnic_presence_tek_mod##c.ln_losingstate_exclpop econ_value_all cincrat_updtd_clclpwr capital_distance_ln global_qtile strata2 strata3 strata4up regimeage_Vdem ClientRelation4, tvc(priormid econ_value_all cincrat_updtd_clclpwr capital_distance_ln  regimeage_Vdem  strata2 strata3 strata4up) texp(ln(_t)) shared(id) forceshared efron

eststo client4_nodecol_excperln
estimates save "client4_nodecol_excperln", replace


//GDP

stset time if potato_any_ModifiedEPR ==1 & colony==0, failure(homeland) exit(time .) origin(time0_minus1) id(id)

***//GDP -- Main result 

stcox mid_current priormid i.coethnic_presence_tek_mod##c.gdpgrowth100 econ_value_all cincrat_updtd_clclpwr capital_distance_ln global_qtile strata2 strata3 strata4up regimeage_Vdem, shared(id) forceshared efron
*estat phtest, rank detail

*TVC needed (.1): regimeage_Vdem  strata2 strata3 strata4up
stcox mid_current priormid i.coethnic_presence_tek_mod##c.gdpgrowth100 econ_value_all cincrat_updtd_clclpwr capital_distance_ln global_qtile strata2 strata3 strata4up regimeage_Vdem, tvc( regimeage_Vdem  strata2 strata3 strata4up) texp(ln(_t)) shared(id) forceshared efron allbase
 eststo main_gdp
 estimates save "main_gdp", replace

***//GDP -- Group size 

stcox mid_current priormid i.coethnic_presence_tek_mod##c.gdpgrowth100 econ_value_all cincrat_updtd_clclpwr capital_distance_ln global_qtile strata2 strata3 strata4up regimeage_Vdem sum_tek_group_size_gain, shared(id) forceshared efron
estat phtest, rank detail


*TVC needed (.1): regimeage_Vdem  strata2 strata3 strata4up

stcox mid_current priormid i.coethnic_presence_tek_mod##c.gdpgrowth100 econ_value_all cincrat_updtd_clclpwr capital_distance_ln global_qtile strata2 strata3 strata4up regimeage_Vdem sum_tek_group_size_gain, tvc( regimeage_Vdem  strata2 strata3 strata4up) texp(ln(_t)) shared(id) forceshared efron allbase
 eststo sum_tek_group_size_gain_gdp
 estimates save "sum_tek_group_size_gain_gdp", replace

***//GDP -- Historical ELF sq. 

stcox mid_current priormid i.coethnic_presence_tek_mod##c.gdpgrowth100 econ_value_all cincrat_updtd_clclpwr capital_distance_ln global_qtile strata2 strata3 strata4up regimeage_Vdem efindex efindex_squared, shared(id) forceshared efron
estat phtest, rank detail
 
*TVC needed (.1):   priormid regimeage_Vdem efindex efindex_squared  strata2 strata3 strata4up

stcox mid_current priormid i.coethnic_presence_tek_mod##c.gdpgrowth100 econ_value_all cincrat_updtd_clclpwr capital_distance_ln global_qtile strata2 strata3 strata4up regimeage_Vdem efindex efindex_squared, tvc(priormid regimeage_Vdem efindex efindex_squared  strata2 strata3 strata4up) texp(ln(_t)) shared(id) forceshared efron allbase
 eststo EFIndex2_nodecol_gdp_ws
 estimates save "EFIndex2_nodecol_gdp_ws", replace

***//GDP -- Polarization 

stcox mid_current priormid i.coethnic_presence_tek_mod##c.gdpgrowth100 econ_value_all cincrat_updtd_clclpwr capital_distance_ln global_qtile strata2 strata3 strata4up regimeage_Vdem actv_groups_count_fill , shared(id) forceshared efron

estat phtest, rank detail

*TVC needed (.1): mid_current actv_groups_count_fill strata2 strata3 strata4up

stcox mid_current priormid i.coethnic_presence_tek_mod##c.gdpgrowth100 econ_value_all cincrat_updtd_clclpwr capital_distance_ln global_qtile strata2 strata3 strata4up regimeage_Vdem actv_groups_count_fill, tvc(mid_current actv_groups_count_fill strata2 strata3 strata4up) texp(ln(_t)) shared(id) forceshared efron
 eststo eprpolar_nodecol_gdp
 estimates save "eprpolar_nodecol_gdp", replace

***//GDP -- State capacity 

stcox mid_current priormid i.coethnic_presence_tek_mod##c.gdpgrowth100 econ_value_all cincrat_updtd_clclpwr capital_distance_ln global_qtile strata2 strata3 strata4up regimeage_Vdem statecapacitycomprehensive , shared(id) forceshared efron
estat phtest, rank detail

*tvc needed: capital_distance_ln regimeage_Vdem

stcox mid_current priormid i.coethnic_presence_tek_mod##c.gdpgrowth100 econ_value_all cincrat_updtd_clclpwr capital_distance_ln global_qtile strata2 strata3 strata4up regimeage_Vdem statecapacitycomprehensive, tvc(capital_distance_ln regimeage_Vdem  strata2 strata3 strata4up) texp(ln(_t)) shared(id) forceshared efron
 eststo cap_nodecol_gdp
 estimates save "cap_nodecol_gdp", replace

***//GDP -- New state

stcox mid_current priormid i.coethnic_presence_tek_mod##c.gdpgrowth100 econ_value_all cincrat_updtd_clclpwr capital_distance_ln global_qtile strata2 strata3 strata4up regimeage_Vdem new_state_5_lose, shared(id) forceshared efron
estat phtest, rank detail
 
*TVC needed (.1): capital_distance_ln regimeage_Vdem  new_state_5_lose  strata2 strata3 strata4up

stcox mid_current priormid i.coethnic_presence_tek_mod##c.gdpgrowth100 econ_value_all cincrat_updtd_clclpwr capital_distance_ln global_qtile strata2 strata3 strata4up regimeage_Vdem new_state_5_lose, tvc(capital_distance_ln regimeage_Vdem  new_state_5_lose  strata2 strata3 strata4up) texp(ln(_t)) shared(id) forceshared efron
eststo newstate_nodecol_gdp_ws
estimates save "newstate_nodecol_gdp_ws", replace

***//GDP -- Clientelistic states 

stcox mid_current priormid i.coethnic_presence_tek_mod##c.gdpgrowth100  econ_value_all cincrat_updtd_clclpwr capital_distance_ln global_qtile strata2 strata3 strata4up regimeage_Vdem v2xnp_client, shared(id) forceshared efron
estat phtest, rank detail

*TVC needed (.1):   regimeage_Vdem    strata2 strata3 strata4up

stcox mid_current priormid i.coethnic_presence_tek_mod##c.gdpgrowth100 econ_value_all cincrat_updtd_clclpwr capital_distance_ln global_qtile strata2 strata3 strata4up regimeage_Vdem v2xnp_client, tvc(     regimeage_Vdem  strata2 strata3 strata4up) texp(ln(_t)) shared(id) forceshared efron
 eststo clientelistic_nodecol_gdp
 estimates save "clientelistic_nodecol_gdp", replace

***//GDP -- Clients of same superpower 

stcox mid_current priormid i.coethnic_presence_tek_mod##c.gdpgrowth100  econ_value_all cincrat_updtd_clclpwr capital_distance_ln global_qtile strata2 strata3 strata4up regimeage_Vdem ClientRelation3, shared(id) forceshared efron
estat phtest, rank detail

*TVC needed (.1):   cincrat_updtd_clclpwr   regimeage_Vdem    strata2 strata3 strata4up

stcox mid_current priormid i.coethnic_presence_tek_mod##c.gdpgrowth100 econ_value_all cincrat_updtd_clclpwr capital_distance_ln global_qtile strata2 strata3 strata4up regimeage_Vdem ClientRelation3, tvc(cincrat_updtd_clclpwr   regimeage_Vdem    strata2 strata3 strata4up) texp(ln(_t)) shared(id) forceshared efron allbase
 eststo CR3_nodecol_gdp_ws
 estimates save "CR3_nodecol_gdp_ws", replace

***//GDP -- Clients ofopposing superpowers

stcox mid_current priormid i.coethnic_presence_tek_mod##c.gdpgrowth100  econ_value_all cincrat_updtd_clclpwr capital_distance_ln global_qtile strata2 strata3 strata4up regimeage_Vdem ClientRelation4, shared(id) forceshared efron
estat phtest, rank detail

*TVC needed (.1):   cincrat_updtd_clclpwr capital_distance_ln  regimeage_Vdem    strata2 strata3 strata4up

stcox mid_current priormid i.coethnic_presence_tek_mod##c.gdpgrowth100 econ_value_all cincrat_updtd_clclpwr capital_distance_ln global_qtile strata2 strata3 strata4up regimeage_Vdem ClientRelation4, tvc(cincrat_updtd_clclpwr capital_distance_ln  regimeage_Vdem    strata2 strata3 strata4up) texp(ln(_t)) shared(id) forceshared efron allbase
 eststo CR4_nodecol_gdp_ws
 estimates save "ClientRelation4_nodecol_gdp_ws", replace

***********
***********
//Table 2: Alternative explanations
***********
***********

stset time if potato_any_ModifiedEPR ==1 & colony==0, failure(homeland) exit(time .) origin(time0_minus1) id(id)


//REGIME TYPE 

stset time if potato_any_ModifiedEPR ==1 & colony==0, failure(homeland) exit(time .) origin(time0_minus1) id(id)

***//Regime type -- Main result

stcox mid_current priormid i.coethnic_presence_tek_mod##i.poly_binary_dem1other0 econ_value_all cincrat_updtd_clclpwr capital_distance_ln global_qtile strata2 strata3 strata4up regimeage_Vdem, shared(id) forceshared efron
estat phtest, rank detail

*TVC needed (.1): priormid econ_value_all capital_distance_ln regimeage_Vdem  strata2 strata3 strata4up
stcox mid_current priormid i.coethnic_presence_tek_mod##i.poly_binary_dem1other0 econ_value_all cincrat_updtd_clclpwr capital_distance_ln global_qtile strata2 strata3 strata4up regimeage_Vdem, tvc( priormid econ_value_all capital_distance_ln regimeage_Vdem strata2 strata3 strata4up) texp(ln(_t)) shared(id) forceshared efron allbase
 eststo main_aut
 estimates save "main_aut", replace

***//Regime type -- Exclude USSR

**needs new stset
stset time if potato_any_ModifiedEPR ==1 & loseccode!=365 & colony==0, failure(homeland) exit(time .) origin(time0_minus1) id(id)

stcox mid_current priormid i.coethnic_presence_tek_mod##i.poly_binary_dem1other0 econ_value_all cincrat_updtd_clclpwr capital_distance_ln global_qtile strata2 strata3 strata4up regimeage_Vdem , shared(id) forceshared efron
*estat phtest, rank detail

*TVC needed (.1):  priormid econ_value_all     strata2 strata3 strata4up

stcox mid_current priormid i.coethnic_presence_tek_mod##i.poly_binary_dem1other0 econ_value_all cincrat_updtd_clclpwr capital_distance_ln global_qtile strata2 strata3 strata4up regimeage_Vdem, tvc(  priormid econ_value_all     strata2 strata3 strata4up ) texp(ln(_t)) shared(id) forceshared efron
eststo soviet_nodecol
estimates save "soviet_nodecol" , replace

***//Regime type -- Group excluded

*go back to original stset
stset time if potato_any_ModifiedEPR ==1 & colony==0, failure(homeland) exit(time .) origin(time0_minus1) id(id)

stcox mid_current priormid  coethnic_presence_tek_mod poly_binary_dem1other0 coethnicXdemocracy econ_value_all cincrat_updtd_clclpwr capital_distance_ln global_qtile strata2 strata3 strata4up regimeage_Vdem excluded, shared(id) forceshared efron
estat phtest, rank detail

*TVC needed (.1): priormid coethnic_presence_tek_mod econ_value_all  capital_distance_ln regimeage_Vdem excluded  strata2 strata3 strata4up

stcox mid_current priormid  coethnic_presence_tek_mod poly_binary_dem1other0 coethnicXdemocracy econ_value_all cincrat_updtd_clclpwr capital_distance_ln global_qtile strata2 strata3 strata4up regimeage_Vdem excluded, tvc(priormid coethnic_presence_tek_mod econ_value_all  capital_distance_ln regimeage_Vdem excluded  strata2 strata3 strata4up) texp(ln(_t)) shared(id) forceshared efron allbase
eststo excluded_nodecol
estimates save "excluded_nodecol", replace

***//Regime type -- Self-determination movement

stcox mid_current priormid i.coethnic_presence_tek_mod##i.poly_binary_dem1other0 econ_value_all cincrat_updtd_clclpwr capital_distance_ln global_qtile strata2 strata3 strata4up regimeage_Vdem sdm, shared(id) forceshared efron
estat phtest, rank detail

*TVC needed (.1):  priormid econ_value_all  capital_distance_ln  regimeage_Vdem   strata2 strata3 strata4up

stcox mid_current priormid i.coethnic_presence_tek_mod##i.poly_binary_dem1other0 econ_value_all cincrat_updtd_clclpwr capital_distance_ln global_qtile strata2 strata3 strata4up regimeage_Vdem sdm, tvc(priormid econ_value_all  capital_distance_ln  regimeage_Vdem   strata2 strata3 strata4up) texp(ln(_t)) shared(id) forceshared efron allbase
eststo sdm_nodecol
estimates save "SDM_nodecol" , replace

***//Regime type -- Democratic dyad

stcox mid_current priormid i.coethnic_presence_tek_mod##i.poly_binary_dem1other0 econ_value_all cincrat_updtd_clclpwr capital_distance_ln global_qtile dem_dyad strata2 strata3 strata4up regimeage_Vdem, shared(id) forceshared efron
estat phtest, rank detail
 

*TVC needed (.01): priormid coethnicXdemocracy econ_value_all capital_distance_ln regimeage_Vdem

stcox mid_current priormid i.coethnic_presence_tek_mod##i.poly_binary_dem1other0 econ_value_all cincrat_updtd_clclpwr capital_distance_ln global_qtile dem_dyad strata2 strata3 strata4up regimeage_Vdem, tvc(priormid coethnicXdemocracy econ_value_all capital_distance_ln regimeage_Vdem strata2 strata3 strata4up) texp(ln(_t)) shared(id) forceshared efron

eststo dem_dyad_nodecol
estimates save "dem_dyad_nodecol", replace

***//Regime type -- Mutual security organization

stcox mid_current priormid coethnic_presence_tek_mod poly_binary_dem1other0 coethnicXdemocracy econ_value_all cincrat_updtd_clclpwr capital_distance_ln global_qtile strata2 strata3 strata4up regimeage_Vdem mutual_defense_org , shared(id) forceshared efron

estat phtest, rank detail

*TVC needed (.1):  econ_value_all cincrat_updtd_clclpwr capital_distance_ln   regimeage_Vdem  strata2 strata3 strata4up

stcox mid_current priormid coethnic_presence_tek_mod poly_binary_dem1other0 coethnicXdemocracy econ_value_all cincrat_updtd_clclpwr capital_distance_ln global_qtile strata2 strata3 strata4up regimeage_Vdem mutual_defense_org, tvc( econ_value_all cincrat_updtd_clclpwr capital_distance_ln   regimeage_Vdem  strata2 strata3 strata4up) texp(ln(_t)) shared(id) forceshared efron allbase
eststo mutual_security_org_nodecol
estimates save "mutual_security_org_nodecol", replace



//EXCLUDED PROPORTION

stset time if potato_any_ModifiedEPR ==1 & colony==0, failure(homeland) exit(time .) origin(time0_minus1) id(id)

***//Excluded proportion -- Main result

stcox mid_current priormid i.coethnic_presence_tek_mod##c.ln_losingstate_exclpop econ_value_all cincrat_updtd_clclpwr capital_distance_ln global_qtile strata2 strata3 strata4up regimeage_Vdem, shared(id) forceshared efron
estat phtest, rank detail

*TVC needed (.1): priormid econ_value_all capital_distance_ln regimeage_Vdem  strata2 strata3 strata4up
stcox mid_current priormid i.coethnic_presence_tek_mod##c.ln_losingstate_exclpop econ_value_all cincrat_updtd_clclpwr capital_distance_ln global_qtile strata2 strata3 strata4up regimeage_Vdem, tvc( priormid econ_value_all capital_distance_ln regimeage_Vdem  strata2 strata3 strata4up) texp(ln(_t)) shared(id) forceshared efron allbase
 eststo main_eth
 estimates save "main_eth", replace

***//Excluded proportion -- Exclude USSR

**needs new stset
stset time if potato_any_ModifiedEPR ==1 & loseccode!=365 & colony==0, failure(homeland) exit(time .) origin(time0_minus1) id(id)

stcox mid_current priormid i.coethnic_presence_tek_mod##c.ln_losingstate_exclpop econ_value_all cincrat_updtd_clclpwr capital_distance_ln global_qtile strata2 strata3 strata4up regimeage_Vdem , shared(id) forceshared efron
estat phtest, rank detail

*TVC needed (.1):  priormid cincrat_updtd_clclpwr    strata2 strata3 strata4up

stcox mid_current priormid i.coethnic_presence_tek_mod##c.ln_losingstate_exclpop econ_value_all cincrat_updtd_clclpwr capital_distance_ln global_qtile strata2 strata3 strata4up regimeage_Vdem, tvc(  priormid cincrat_updtd_clclpwr    strata2 strata3 strata4up) texp(ln(_t)) shared(id) forceshared efron
eststo soviet_nodecol_excperln
estimates save "soviet_nodecol_excperln" , replace
 

***//Excluded proportion -- Group excluded

*go back to original stset
stset time if potato_any_ModifiedEPR ==1 & colony==0, failure(homeland) exit(time .) origin(time0_minus1) id(id)

stcox mid_current priormid  i.coethnic_presence_tek_mod##c.ln_losingstate_exclpop econ_value_all cincrat_updtd_clclpwr capital_distance_ln global_qtile strata2 strata3 strata4up regimeage_Vdem excluded, shared(id) forceshared efron

estat phtest, rank detail


*TVC needed (.1): priormid econ_value_all capital_distance_ln regimeage_Vdem excluded  strata2 strata3 strata4up

stcox mid_current priormid  i.coethnic_presence_tek_mod##c.ln_losingstate_exclpop econ_value_all cincrat_updtd_clclpwr capital_distance_ln global_qtile strata2 strata3 strata4up regimeage_Vdem excluded, tvc(priormid econ_value_all capital_distance_ln regimeage_Vdem excluded  strata2 strata3 strata4up) texp(ln(_t)) shared(id) forceshared efron allbase
eststo excluded_nodecol_excperln_s
estimates save "excluded_nodecol_excperln_s", replace

***//Excluded proportion -- Self-determination movement

stcox mid_current priormid i.coethnic_presence_tek_mod##c.ln_losingstate_exclpop econ_value_all cincrat_updtd_clclpwr capital_distance_ln global_qtile strata2 strata3 strata4up regimeage_Vdem sdm, shared(id) forceshared efron
*estat phtest, rank detail

*TVC needed (.1):  priormid  econ_value_all  capital_distance_ln regimeage_Vdem   strata2 strata3 strata4up

stcox mid_current priormid i.coethnic_presence_tek_mod##c.ln_losingstate_exclpop econ_value_all cincrat_updtd_clclpwr capital_distance_ln global_qtile strata2 strata3 strata4up regimeage_Vdem sdm, tvc(priormid  econ_value_all  capital_distance_ln regimeage_Vdem   strata2 strata3 strata4up) texp(ln(_t)) shared(id) forceshared efron allbase
eststo sdm_nodecol_excperln
estimates save "SDM_nodecol_excperln" , replace

***//Excluded proportion -- Democratic dyad

stcox mid_current priormid i.coethnic_presence_tek_mod##c.ln_losingstate_exclpop econ_value_all cincrat_updtd_clclpwr capital_distance_ln global_qtile strata2 strata3 strata4up regimeage_Vdem dem_dyad, shared(id) forceshared efron
estat phtest, rank detail
 

*TVC needed (.1): priormid econ_value_all capital_distance_ln regimeage_Vdem strata2 strata3 strata4up

stcox mid_current priormid i.coethnic_presence_tek_mod##c.ln_losingstate_exclpop econ_value_all cincrat_updtd_clclpwr capital_distance_ln global_qtile strata2 strata3 strata4up regimeage_Vdem dem_dyad, tvc(priormid econ_value_all capital_distance_ln regimeage_Vdem strata2 strata3 strata4up) texp(ln(_t)) shared(id) forceshared efron

eststo dem_dyad_nodecol_excperln
estimates save "dem_dyad_nodecol_excperln", replace

***//Excluded proportion -- Mutual security organization

stcox mid_current priormid i.coethnic_presence_tek_mod##c.ln_losingstate_exclpop econ_value_all cincrat_updtd_clclpwr capital_distance_ln global_qtile strata2 strata3 strata4up regimeage_Vdem mutual_defense_org , shared(id) forceshared efron
estat phtest, rank detail


*TVC needed (.1):   econ_value_all cincrat_updtd_clclpwr capital_distance_ln regimeage_Vdem  strata2 strata3 strata4up

stcox mid_current priormid i.coethnic_presence_tek_mod##c.ln_losingstate_exclpop econ_value_all cincrat_updtd_clclpwr capital_distance_ln global_qtile strata2 strata3 strata4up regimeage_Vdem mutual_defense_org, tvc( econ_value_all cincrat_updtd_clclpwr capital_distance_ln regimeage_Vdem  strata2 strata3 strata4up) texp(ln(_t)) shared(id) forceshared efron allbase
eststo mutual_sec_nodecol_excperln
estimates save "mutual_sec_nodecol_excperln", replace



//GDP 

stset time if potato_any_ModifiedEPR ==1 & colony==0, failure(homeland) exit(time .) origin(time0_minus1) id(id)

***//GDP -- Main result

stcox mid_current priormid i.coethnic_presence_tek_mod##c.gdpgrowth100 econ_value_all cincrat_updtd_clclpwr capital_distance_ln global_qtile strata2 strata3 strata4up regimeage_Vdem, shared(id) forceshared efron
*estat phtest, rank detail

*TVC needed (.1): regimeage_Vdem  strata2 strata3 strata4up
stcox mid_current priormid i.coethnic_presence_tek_mod##c.gdpgrowth100 econ_value_all cincrat_updtd_clclpwr capital_distance_ln global_qtile strata2 strata3 strata4up regimeage_Vdem, tvc( regimeage_Vdem  strata2 strata3 strata4up) texp(ln(_t)) shared(id) forceshared efron allbase
 eststo main_gdp
 estimates save "main_gdp", replace

***//GDP -- Exclude USSR

**needs new stset
stset time if potato_any_ModifiedEPR ==1 & loseccode!=365 & colony==0, failure(homeland) exit(time .) origin(time0_minus1) id(id)

stcox mid_current priormid i.coethnic_presence_tek_mod##c.gdpgrowth100 econ_value_all cincrat_updtd_clclpwr capital_distance_ln global_qtile strata2 strata3 strata4up regimeage_Vdem , shared(id) forceshared efron
estat phtest, rank detail
 
*TVC needed (.1):  priormid  strata2 strata3 strata4up

stcox mid_current priormid i.coethnic_presence_tek_mod##c.gdpgrowth100 econ_value_all cincrat_updtd_clclpwr capital_distance_ln global_qtile strata2 strata3 strata4up regimeage_Vdem, tvc(priormid strata2 strata3 strata4up ) texp(ln(_t)) shared(id) forceshared efron
eststo soviet_nodecol_gdp
estimates save "soviet_nodecol_gdp" , replace
 

***//GDP -- Group excluded

*go back to original stset
stset time if potato_any_ModifiedEPR ==1 & colony==0, failure(homeland) exit(time .) origin(time0_minus1) id(id)

stcox mid_current priormid  i.coethnic_presence_tek_mod##c.gdpgrowth100 econ_value_all cincrat_updtd_clclpwr capital_distance_ln global_qtile strata2 strata3 strata4up regimeage_Vdem excluded, shared(id) forceshared efron
estat phtest, rank detail
 
*TVC needed (.1): regimeage_Vdem excluded  strata2 strata3 strata4up

stcox mid_current priormid  i.coethnic_presence_tek_mod##c.gdpgrowth100 econ_value_all cincrat_updtd_clclpwr capital_distance_ln global_qtile strata2 strata3 strata4up regimeage_Vdem excluded, tvc(regimeage_Vdem excluded  strata2 strata3 strata4up) texp(ln(_t)) shared(id) forceshared efron allbase
eststo excluded_nodecol_gdp_ws
estimates save "excluded_nodecol_gdp_ws", replace

***//GDP -- Self-determination movement

stcox mid_current priormid i.coethnic_presence_tek_mod##c.gdpgrowth100 econ_value_all cincrat_updtd_clclpwr capital_distance_ln global_qtile strata2 strata3 strata4up regimeage_Vdem sdm, shared(id) forceshared efron
estat phtest, rank detail

*TVC needed (.1):  regimeage_Vdem  strata2 strata3 strata4up

stcox mid_current priormid i.coethnic_presence_tek_mod##c.gdpgrowth100 econ_value_all cincrat_updtd_clclpwr capital_distance_ln global_qtile strata2 strata3 strata4up regimeage_Vdem sdm, tvc(regimeage_Vdem  strata2 strata3 strata4up) texp(ln(_t)) shared(id) forceshared efron allbase
eststo sdm_nodecol_gdp_ws
estimates save "SDM_nodecol_gdp_ws" , replace

***//GDP -- Democratic dyad

stcox mid_current priormid i.coethnic_presence_tek_mod##c.gdpgrowth100 econ_value_all cincrat_updtd_clclpwr capital_distance_ln global_qtile strata2 strata3 strata4up regimeage_Vdem dem_dyad, shared(id) forceshared efron
estat phtest, rank detail
 
*TVC needed (.1):   regimeage_Vdem  strata2 strata3 strata4up

stcox mid_current priormid i.coethnic_presence_tek_mod##c.gdpgrowth100 econ_value_all cincrat_updtd_clclpwr capital_distance_ln global_qtile strata2 strata3 strata4up regimeage_Vdem dem_dyad, tvc(regimeage_Vdem  strata2 strata3 strata4up) texp(ln(_t)) shared(id) forceshared efron

eststo dem_dyad_nodecol_gdp_ws
estimates save "dem_dyad_nodecol_gdp_ws", replace

***//GDP -- Mutual security organization

stcox mid_current priormid i.coethnic_presence_tek_mod##c.gdpgrowth100 econ_value_all cincrat_updtd_clclpwr capital_distance_ln global_qtile strata2 strata3 strata4up regimeage_Vdem mutual_defense_org , shared(id) forceshared efron
estat phtest, rank detail
 
*TVC needed (.1):   cincrat_updtd_clclpwr regimeage_Vdem strata2 strata3 strata4up

stcox mid_current priormid i.coethnic_presence_tek_mod##c.gdpgrowth100 econ_value_all cincrat_updtd_clclpwr capital_distance_ln global_qtile strata2 strata3 strata4up regimeage_Vdem mutual_defense_org, tvc( cincrat_updtd_clclpwr  regimeage_Vdem strata2 strata3 strata4up) texp(ln(_t)) shared(id) forceshared efron allbase
eststo mutual_sec_nodecol_gdp_ws
estimates save "mutual_sec_nodecol_gdp_ws", replace

